//动态屏幕适配
(function (doc, win) {
  var docEl = doc.documentElement,
    resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
    recalc = function () {
      var clientWidth = docEl.clientWidth;
      if (!clientWidth) return;
      docEl.style.fontSize = 40 * (clientWidth / 750) + 'px';

    };

  if (!doc.addEventListener) return;
  win.addEventListener(resizeEvt, recalc, false);
  doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);

//所有link的头部，全局变量
var orginlink = 'http://api.kktoken.io:7001';


//小数精度处理方法，精确到小数后三位
function changeTwoDecimal_f(floatvar) {
  var f_x = parseFloat(floatvar);
  if (isNaN(f_x)) {
    return '0.0';
  }
  var f_x = Math.round(f_x * 10, 3) / 10;
  var s_x = f_x.toString();
  var pos_decimal = s_x.indexOf('.');
  if (pos_decimal < 0) {
    pos_decimal = s_x.length;
    s_x += '.';
  }
  while (s_x.length <= pos_decimal + 1) {
    s_x += '0';
  }
  return s_x;
}

function changeTwoDecimal_f2(floatvar) {
  var f_x = parseFloat(floatvar);
  if (isNaN(f_x)) {
    return '0.000';
  }
  var f_x = Math.round(f_x * 100, 5) / 100;
  var s_x = f_x.toString();
  var pos_decimal = s_x.indexOf('.');
  if (pos_decimal < 0) {
    pos_decimal = s_x.length;
    s_x += '.';
  }
  while (s_x.length <= pos_decimal + 1) {
    s_x += '0';
  }
  return s_x;
}
//返回上一层
function backBefore() {
  window.history.go(-1);
  //			return false;
}

//打开新窗口
function todetail(index) {
  localStorage.setItem("dataListindex",index);
  $(window.parent.frameDisplay());
}

//打开新窗口
function todetail2(index) {
  localStorage.setItem("dataListindex",index);
  window.location.href = "../detail/detail.html";     //在同当前窗口中打开窗口
}

//判断交易所名称
function getjysName(id) {
  switch (parseInt(id)) {
    case 1:
      return "Liqui";
    case 2:
      return "Gate";
    case 3:
      return "Kraken";
    case 4:
      return "Binance";
    case 5:
      return "Bittrex";
    case 6:
      return "Bitfinex";
    case 7:
      return "Poloniex";
    case 8:
      return "Huobi";
    case 9:
      return "Okex";
    case 10:
      return "Coolcoin";
    case 11:
      return "Bitstamp";
    case 12:
      return "Hitbtc";
  }
}

//获取涨的颜色
function getRiseColor(){
  return localStorage.getItem("zhangColor") == 1 ? '#e61303' : '#03A626';
}
//获取跌的颜色
function getFallColor(){
  return localStorage.getItem("zhangColor") == 1 ? '#03A626' : '#e61303';
}
